package com.springboot.blog.config;


import com.springboot.blog.constants.UploadConstants;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyBlogWebMvcConfigurer implements WebMvcConfigurer {
//    @Autowired
//    private AdminLoginInterceptor adminLoginInterceptor;
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        // 添加一个拦截器，拦截以/admin为前缀的url路径
//        registry.addInterceptor(adminLoginInterceptor)
//                .addPathPatterns("/admin/**")
//                .excludePathPatterns("/admin/login");
//    }
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //文件磁盘图片url 映射
        //配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径
        registry.addResourceHandler(UploadConstants.ACCESS_PATH+"**").addResourceLocations("file:"+UploadConstants.BASE_PATH);
    }
}
